#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Copyright © 启明星辰 版权所有
# @Time    : 2024/6/7 16:54
# @Author  : 胡浩浩
# @File    : case_model.py
# @IDE     : PyCharm
# @description :
from typing import Union, Optional

from pydantic import BaseModel


class CaseRequestBase(BaseModel):
    path: str
    method: str
    headers: Union[None, dict]
    data: Union[None, dict, list]
    params: Union[None, dict]
    files: Union[None, dict]


class CaseRequestLogs(CaseRequestBase):
    path: Union[None, str]
    method: Union[None, str]
    headers: Union[None, dict]
    data: Union[None, dict, list]
    params: Union[None, dict]
    files: Union[None, dict]


class CheckerBase(BaseModel):
    check_result: Optional[str] = None
    code: Union[None, int]
    json: Union[None, list]
    re: Union[None, list]
    contains: Union[None, list]


class CaseStepBase(BaseModel):
    step_name: str
    step_desc: str
    wait_time: Union[int, float]
    set_up: Union[None, list]
    tear_down: Union[None, list]
    request: CaseRequestBase
    sql_data: Union[None, dict]
    downloads: Union[None, dict]
    extract: Union[None, dict]
    checker: CheckerBase


class CheckerLogs(CheckerBase):
    check_result: Optional[str] = None
    code: Union[None, int]
    json: Union[None, list]
    re: Union[None, list]
    contains: Union[None, list]


class CaseStepLogs(CaseStepBase):
    step_name: Union[None, str]
    step_desc: Union[None, str]
    wait_time: Union[None, int, float]
    set_up: Union[None, list]
    tear_down: Union[None, list]
    request: CaseRequestLogs
    response: Union[None, str, bytes, dict, list, int]
    sql_data: Union[None, list]
    downloads: Union[None, list]
    extract: Union[None, list]
    checker: CheckerLogs


class CaseSuiteBase(BaseModel):
    suite_name: str
    suite_desc: str
    variables: Union[None, dict]
    test_steps: list[CaseStepBase]


class CaseSuiteLogs(CaseSuiteBase):
    suite_name: Optional[str] = None
    suite_desc: Optional[str] = None
    variables: Union[None, list]
    test_steps: Optional[list] = None
